//
//  LLNWFileDownloadTask+LLAudioDownload.m
//  LLFoundation
//
//  Created by my_liu on 2016/11/14.
//  Copyright © 2016年 . All rights reserved.
//

#import "LLNWFileDownloadTask+LLAudioDownload.h"
#import "LLAudioFileUitil.h"

@implementation LLNWFileDownloadTask (LLAudioDownload)
+ (LLNWFileDownloadTask *)taskWithAudioFile:(LLAudioModel*)audioFile withObserver:(NSObject*)observer getTaskIdentifier:(NSUInteger *)taskIdentifier
{
    if (!audioFile.remotePath) {
        //        NSLog(@"LLNWFileDownloadTask+CUCFAudioDownload 没有远程下载地址无法下载文件");
        return nil;
    }
    
    /* 设定缓存路径 */
    if (!audioFile.tempEncodeFilePath) {
        [LLAudioFileUitil setupAudioFileTempEncodeFilePath:audioFile];
    }
    
    LLNWFileDownloadTask *task = [LLNWFileDownloadTask taskWithDownloadUrl:audioFile.remotePath withCachePath:audioFile.tempEncodeFilePath withObserver:observer getTaskIdentifer:taskIdentifier];
    task.userInfo = @{@"audioFile": audioFile};
    
    return task;
}

@end
